package com.hy.mydesktop.shared.persistence.domain.gxt;

import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.IndexColumn;

import net.sf.gilead.annotations.ServerOnly;

import com.hy.mydesktop.client.component.mvc.event.EventStructureMetaModel;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.ComponentMetaDataConstants;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;

@Entity
@Table(name="t_Item_Of_AssociateToWindow")
public class ItemOfAssociateToWindow2012_2_13 extends MyBaseModel {
	

	
	public ItemOfAssociateToWindow2012_2_13() {
		super();
	}

	public ItemOfAssociateToWindow2012_2_13(Map<String, Object> properties) {
		super(properties);
	}

	/*@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER,optional=false)
	@JoinColumn(name="gxtComponentMetaNodeModel_identifier")
	public GxtComponentMetaNodeModel getGxtComponentMetaNodeModel() {
		return super.get(ComponentMetaDataConstants.GXT_COMPONENT__METANODEMODEL);
	}

	public void setGxtComponentMetaNodeModel(GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {
		super.set(ComponentMetaDataConstants.GXT_COMPONENT__METANODEMODEL, gxtComponentMetaNodeModel);
	}*/
	
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name="parent_identifier")
	public ItemOfAssociateToWindow2012_2_13 getParentItem ( )
	{
		return this.get (ComponentMetaDataConstants.PARENT_ITEM ) ;
	}
	
	public void setParentItem (ItemOfAssociateToWindow2012_2_13 parentItem )
	{
		this.set (ComponentMetaDataConstants.PARENT_ITEM,  parentItem) ;
	}
	
	
	@OneToMany(mappedBy="parentItem",cascade={CascadeType.REMOVE,CascadeType.ALL},fetch=FetchType.EAGER)
	@IndexColumn(name="list_index")
	public List<ItemOfAssociateToWindow2012_2_13> getChildrenItems ( )
	{
		return this.get (ComponentMetaDataConstants.CHILDREN_ITEMS ) ;
	}
	
	public void setChildrenItems (List<ItemOfAssociateToWindow2012_2_13> childrenItems )
	{
		this.set (ComponentMetaDataConstants.CHILDREN_ITEMS,  childrenItems) ;
	}
	
	
	
	/*public int getIndex ( )
	{
		return this.get (ComponentMetaDataConstants.INDEX ,0) ;
	}
	
	public void setIndex (int index )
	{
		this.set (ComponentMetaDataConstants.INDEX,  index) ;
	}*/
	
	public String getName() {
		return super.get(ComponentMetaDataConstants.NAME);
	}

	public void setName(String name) {
		super.set(ComponentMetaDataConstants.NAME, name);
	}
	


	//@Transient
	//@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH},fetch=FetchType.EAGER)
	public GxtAppEventType getRegisterEventType() {
//		return super.get("registerEventTypes");
		return super.get(MetaDataConstants.APP_EVENT_TYPE);
	}

	public void setRegisterEventType(GxtAppEventType registerEventType) {
		super.set(MetaDataConstants.APP_EVENT_TYPE, registerEventType);
	}
	

	public String getText() {
		return super.get(ComponentMetaDataConstants.TEXT);
	}

	public void setText(String text) {
		super.set(ComponentMetaDataConstants.TEXT, text);
	}
	
	
	public String getIcon() {
		return super.get(ComponentMetaDataConstants.ICON);
	}

	public void setIcon(String icon) {
		super.set(ComponentMetaDataConstants.ICON, icon);
	}
	

	//@Column(nullable=true)
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	public GxtToSeamServiceParameter getGxtToSeamServiceParameter() {
		return super.get(MetaDataConstants.GXT_TO_SEAM_SERVICEPARAMETER_MODEL);
	}

	public void setGxtToSeamServiceParameter(GxtToSeamServiceParameter gxtToSeamServiceParameter) {
		super.set(MetaDataConstants.GXT_TO_SEAM_SERVICEPARAMETER_MODEL, gxtToSeamServiceParameter);
	}
	
	//@Column(nullable=true)
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	public EventStructureMetaModel getEventStructureMetaModel() {
		return super.get(MetaDataConstants.EVENT_STRUCTURE_METAMODEL);
	}

	public void setEventStructureMetaModel(EventStructureMetaModel eventStructureMetaModel) {
		super.set(MetaDataConstants.EVENT_STRUCTURE_METAMODEL, eventStructureMetaModel);
	}
	
	/**
	 * 
	 * <ul>
	 * <li>方法含义：获取将要创建的控件Component的真实类型</li>
	 * <li>方法作者：花宏宇</li>
	 * <li>编写日期：2010-8-28；时间：下午上午11:12:55</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @return
	 */
	//@Transient
	@Enumerated(EnumType.STRING)
	@Column(nullable=true)
	//@ServerOnly
	public ComponentTypeEnum getComponentTypeEnum ( )
	{
		return this.get (MetaDataConstants.COMPONENT_MODEL_TYPE ) ;
	}
		
	

	/**
	 * 
	 * <ul>
	 * <li>方法含义：设置要创建的控件Component的真实类型</li>
	 * <li>方法作者：花宏宇</li>
	 * <li>编写日期：2010-8-28；时间：下午上午11:13:57</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 * @param componentTypeEnum
	 */
	public void setComponentTypeEnum (ComponentTypeEnum componentTypeEnum )
	{
		this.set (MetaDataConstants.COMPONENT_MODEL_TYPE,  componentTypeEnum) ;
	}
	

	public int getComponentTypeEnumIndex ( )
	{
		return this.get (MetaDataConstants.COMPONENT_MODEL_TYPE_INDEX ,0) ;
	}
	
	public void setComponentTypeEnumIndex (int componentTypeEnumIndex )
	{
		this.set (MetaDataConstants.COMPONENT_MODEL_TYPE_INDEX,  componentTypeEnumIndex) ;
	}
	
	public static  ItemOfAssociateToWindow2012_2_13 addGxtToSeamServiceParameterToItem(ItemOfAssociateToWindow2012_2_13 itemOfAssociateToWindow,String name,String serviceComponentName ,
			String serviceMethodName ) {
		itemOfAssociateToWindow.setGxtToSeamServiceParameter(new GxtToSeamServiceParameter(serviceComponentName , serviceMethodName ));
		itemOfAssociateToWindow.setName(name);
		return itemOfAssociateToWindow;
	}

	
	public static ItemOfAssociateToWindow2012_2_13 addGxtToSeamServiceParameterToItem(String name,String serviceComponentName ,
			String serviceMethodName ) {
		return	addGxtToSeamServiceParameterToItem(new ItemOfAssociateToWindow2012_2_13(), name, serviceComponentName ,
				 serviceMethodName );
	}
	
	/*registereventtypes	
	dispachereventtypes			
	ComponentTypeEnum.DESKTOP_MENUITEM_MODEL.ordinal()
	ComponentTypeEnum.MENUITEM_MODEL.ordinal()	
	gxttoseamserviceparametermodel
	children*/
	/*@OneToMany(mappedBy="parentItem",cascade={CascadeType.REMOVE,CascadeType.ALL},fetch=FetchType.EAGER)
	public Set<ItemOfAssociateToWindow> getChildrenItems ( )
	{
		return this.get (ComponentMetaDataConstants.CHILDREN_ITEMS ) ;
	}
	
	public void setChildrenItems (Set<ItemOfAssociateToWindow> childrenItems )
	{
		this.set (ComponentMetaDataConstants.CHILDREN_ITEMS,  childrenItems) ;
	}*/

}
